//  
//  DropBox.cs
//  
//  Author:
//       Thomas Beckett <thomas.beckett@gmail.com>
// 
//  Copyright (c) 2011 Thomas Beckett
// 
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
using System;
using Gtk;

namespace Oghma
{
	class MainClass
	{
		private static StatusIcon tray_icon;
		private static AboutDialog dlgAbout;
				
		public static void Main (string[] args)
		{
			Application.Init ();
//			MainWindow win = new MainWindow ();
//			win.Show ();
			
			tray_icon = new StatusIcon(Gdk.Pixbuf.LoadFromResource("Oghma.Resources.asterisk_icon.png"));
			tray_icon.Visible = true;
			tray_icon.Tooltip = "Oghma - asterisk toolbox";
			tray_icon.PopupMenu += StatusIconMenu;
			Application.Run ();
		}
		
		protected static void StatusIconMenu(object sender, EventArgs e)
		{
			Menu popupMenu = new Menu();
			MenuItem mnuDropBox = new MenuItem("Show Drop Box");
			mnuDropBox.Show();	
			mnuDropBox.Activated += new EventHandler(ShowHideDropBox);
			SeparatorMenuItem mnuSep = new SeparatorMenuItem();
			MenuItem mnuSettings = new MenuItem("Settings");
			mnuSettings.Show();
			mnuSettings.Activated += new EventHandler(ShowSettings);
			MenuItem mnuAbout = new MenuItem("About Oghma");
			mnuAbout.Show();
			mnuAbout.Activated += new EventHandler(ShowAbout);
			MenuItem mnuExit = new MenuItem("Exit Oghma");
			mnuExit.Show();
			mnuExit.Activated += new EventHandler(ExitOghma);
			
			popupMenu.Append(mnuDropBox);
			popupMenu.Append(mnuSep);
			popupMenu.Append(mnuSettings);
			popupMenu.Append(mnuAbout);
			popupMenu.Append(mnuExit);
			
			popupMenu.Popup(null,null,null,3,Gtk.Global.CurrentEventTime);
			
		}
		
		protected static void ShowHideDropBox(object sender, EventArgs e)
		{
			//TODO: Implement drop box (take from project)
		}
		
		protected static void ShowSettings(object sender, EventArgs e)
		{
			//TODO: implement settings dialog
		}
		
		protected static void ShowAbout(object sender, EventArgs e)
		{
			//TODO: Implement About dialog
			dlgAbout = new AboutDialog();
			dlgAbout.Icon = new Gdk.Pixbuf(null,"Oghma.Resources.asterisk_icon.png");
			dlgAbout.Logo = new Gdk.Pixbuf(null,"Oghma.Resources.asterisk_icon.png");
			dlgAbout.ProgramName = "Oghma - asterisk toolbox";
			//dlgAbout.Version = "0.1";
			dlgAbout.Comments = "Program for working with asterisk";
			dlgAbout.License = @"
Oghma - Asterisk toolbox

Author: Thomas Beckett <thomas.beckett@gmail.com>
 
Copyright (c) 2011 Thomas Beckett
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.";

			dlgAbout.Authors = new string[] {"Thomas Beckett"};
			dlgAbout.Website = "http://thomasbeckett.org";
			dlgAbout.Response += new ResponseHandler(CloseAbout);
			dlgAbout.Run();
		}
		protected static void CloseAbout(object sender, ResponseArgs e)
		{
			if (e.ResponseId == ResponseType.Cancel || e.ResponseId ==  ResponseType.DeleteEvent)
				dlgAbout.Destroy();
		}
		
		protected static void ExitOghma(object sender, EventArgs e)
		{
			//TODO: Implement Exiting the program
			Application.Quit();
		}
	}
}

